package edu.jd.movieplatform.user.comment;

import edu.jd.movieplatform.common.Result;
import edu.jd.movieplatform.user.long_comment.LongComment;
import edu.jd.movieplatform.user.long_comment.LongCommentDto;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @descriptions:
 * @data: 2021/7/9 22:44
 */
@RestController
@RequestMapping("/user/comment")
public class CommentAPI {
    @Resource
    private CommentService Service;

    /**
     * 创建评论
     *     需要传入数据
     *     private String cust_username;
     *     private Integer mov_id;
     *     private String com_text;
     *     private float com_score;
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody CommentDto dto){
        boolean ok = Service.CreateComment(dto);
        if(ok){return Result.success();}
        return Result.fail(Result.ERR_CODE_BUSINESS,"评论出错！");
    }
    /**
     * 回复评论
     *     需要传入数据
     *     private String cust_username;
     *     private Integer mov_id;
     *     private String com_text;
     *     private Integer comment_host_id;
     */
    @PostMapping("/replyComment")
    public Result replyComment(@RequestBody CommentDto dto){
        boolean ok = Service.ReplyComment(dto);
        if(ok){return Result.success();}
        return Result.fail(Result.ERR_CODE_BUSINESS,"回复出错！");
    }
    /**
     * 获取评论
     * private Integer mov_id;
     */
    @PostMapping("/getComment")
    public Result getHostComment(@RequestBody CommentDto dto){
        Integer mov_id=dto.getMov_id();
        List<Comment> list = Service.GetCommentList(mov_id);
        return Result.success(list);
    }

}
